package com.tengju.support.domain.model.resource;

import lombok.Getter;

import java.util.Arrays;

@Getter
public enum StarLevel {
    NONE(0,"没有星级","无星"),
    CITY_STAR_ONE(10, "城市服务商1星","城市服务商1星"),
    CITY_STAR_TWO(20, "城市服务商2星","城市服务商2星"),
    CITY_STAR_THREE(30, "城市服务商3星","城市服务商3星"),
    CITY_STAR_FOUR(40, "城市服务商4星","城市服务商4星"),
    EC(50, "大区运营商EC","大区运营商"),
    SEC(60, "大区运营商SEC","大区运营商"),
    EEC(70,"大区运营商EEC","大区运营商");

    private Integer code;
    private String desc;
    private String showName;

    StarLevel(Integer code, String desc, String showName) {
        this.code = code;
        this.desc = desc;
        this.showName = showName;
    }


    public static StarLevel parseByCode(Integer code) {
        return Arrays.stream(StarLevel.values())
                .filter(k -> k.getCode().equals(code))
                .findFirst().orElse(null);
    }

    /**
     * 是否升星
     * @return
     */
    public static boolean isRise(Integer curStarLevel,Integer targetStarLevel) {
        return targetStarLevel > curStarLevel;
    }

    public boolean isHigher(StarLevel starLevel) {
        if (starLevel == null) {
            return false;
        }
        return this.getCode() > starLevel.getCode();
    }

}
